//配置路由全局前置守卫导航-----------------------
import router from "@/router";
import { resetRouter } from "@/router";
// 配置全局前置守卫导航
import store from '@/store'
router.beforeEach((to, from, next) => {
    if (to.matched.length == 0 || to.matched.some(ele => ele.meta.islogin)) {
        if (store.state.login.logininfo.role) {
            if (store.state.menus.activemenus.length != 0) {
                // alert('我来这了')
                next()
            } else {
                store.dispatch('menus/getMenusList').then((mybaseRoutes) => {
                    console.log(mybaseRoutes, '我也啦啦啦');
                    resetRouter();
                    mybaseRoutes.forEach((ele) => {
                        router.addRoute(ele);
                    });
                })
                // console.log();

                next()
            }

        } else {
            next('/login')
        }
    }
    else {
        next()
    }
})